package com.fjd.mapper;

import com.fjd.entity.Follow;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface FollowerMapper {

    @Insert("insert into follower (from_id, to_id) VALUES (#{fromId},#{toId})")
    void insert(String fromId, String toId);


    @Delete("delete from follower where from_id = #{fromId} and to_id = #{toId}")
    void delete(String fromId, String toId);

    @Select("select * from follower where from_id = #{fromId}")
    List<Follow> list(String fromId);

    @Select("select * from follower where from_id =#{fromId} and to_id = #{toId}")
    Follow getByFromIdAndToId(String fromId, String toId);

    @Select("select count(*) from follower where to_id = #{anchorId}")
    String getFollowSum(String anchorId);
}
